from pydantic import BaseModel, Field
from typing import List, Optional
from datetime import datetime, date


class BaseAppointmentSpace(BaseModel):
    sort: Optional[int] = Field(0)
    city_id: Optional[int] = Field(0)
    type: Optional[int] = Field(1)
    name: Optional[str] = Field(None)
    english_name: Optional[str] = Field(None)
    intro: Optional[str] = Field(None)
    phone: Optional[str] = Field(None)
    address: Optional[str] = Field(None)
    date: Optional[str] = Field(None)
    interval :Optional[int] = Field(30)
    start: Optional[str] = Field(None)
    end: Optional[str] = Field(None)
    slot : Optional[str] = Field(None)
    parking_on : Optional[bool] = True
    parking_cost: Optional[int] = Field(0)
    project_appointment : Optional[bool] = True
    status : Optional[bool] = True
    picture : Optional[str] = Field(None)
    images: Optional[str] = Field(None)
    content_pic: Optional[str] = Field(None)
    project_roles: Optional[str] = Field(None)
    lat: Optional[str] = Field(None)
    lon: Optional[str] = Field(None)


class AppointmentSpaceCreate(BaseAppointmentSpace):
    date: Optional[list] = None
    slot: Optional[list] = None
    images: Optional[list] = None
    content_pic: Optional[list] = None
    project_roles: Optional[list] = None

class AppointmentSpaceUpdate(BaseAppointmentSpace):
    id: int
    date: Optional[list] = None
    slot: Optional[list] = None
    images: Optional[list] = None
    content_pic: Optional[list] = None
    project_roles: Optional[list] = None
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseAppointmentProject(BaseModel):
    sort: Optional[int] = Field(0)
    pid: Optional[int] = Field(0)
    type: Optional[int] = Field(0)
    interval: Optional[int] = Field(0)
    name: Optional[str] = Field(None)
    online : Optional[bool] = True
    status: Optional[bool] = True
    goods_id: Optional[int] = Field(0, description="关联商品ID")
    sku_id: Optional[int] = Field(0, description="关联规格ID")
    cover: Optional[str] = Field("", description="封面")
    project_images: Optional[list] = None

class AppointmentProjectCreate(BaseAppointmentProject):
    ...

class AppointmentProjectUpdate(BaseAppointmentProject):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseAppointmentInstrument(BaseModel):
    space_id: Optional[int] = Field(0)
    instrument_id: Optional[int] = Field(0)
    interval: Optional[int] = Field(30)
    num: Optional[int] = Field(0)
    date: Optional[str] = Field(None)

class AppointmentInstrumentCreate(BaseAppointmentInstrument):
    date: Optional[list] = None

class AppointmentInstrumentUpdate(BaseAppointmentInstrument):
    id: int
    date: Optional[list] = None
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseAppointmentDesigner(BaseModel):
    sort: Optional[int] = Field(1)
    name: Optional[str] = Field(None)
    space_id: Optional[str] = Field(None)
    type: Optional[int] = Field(0)
    doctor_type: Optional[str] = Field(None)
    title: Optional[str] = Field(None)
    intro: Optional[str] = Field(None)
    picture: Optional[str] = Field(None)
    images: Optional[str] = Field(None)
    status: Optional[bool] = True
    open_roles: Optional[str] = Field(None)
    close_roles: Optional[str] = Field(None)
    project_roles: Optional[str] = Field(None)


class AppointmentDesignerCreate(BaseAppointmentDesigner):
    space_id: Optional[list] = None
    images: Optional[list] = None
    open_roles: Optional[list] = None
    close_roles: Optional[list] = None
    project_roles: Optional[list] = None
    doctor_type: Optional[list] = None

class AppointmentDesignerUpdate(BaseAppointmentDesigner):
    id: int
    space_id: Optional[list] = None
    images: Optional[list] = None
    open_roles: Optional[list] = None
    close_roles: Optional[list] = None
    project_roles: Optional[list] = None
    doctor_type: Optional[list] = None
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseAppointmentSalon(BaseModel):
    sort: Optional[int] = Field(0)
    role_id: Optional[str] = Field(None)
    kind: Optional[int] = Field(0)
    type_id: Optional[int] = Field(0)
    is_brand: Optional[bool] = True
    name: Optional[str] = Field(None)
    english_name: Optional[str] = Field(None)
    desc: Optional[str] = Field(None)
    picture: Optional[str] = Field(None)
    content_pic: Optional[str] = Field(None)
    start_time: Optional[str] = Field("2024-01-01 00:00:00")
    end_time: Optional[str] = Field("2024-01-01 00:00:00")
    date: Optional[str] = Field("2024-01-01 00:00:00")
    city_id: Optional[int] = Field(0)
    space_id: Optional[int] = Field(0)
    location: Optional[str] = Field(None)
    number: Optional[int] = Field(0)
    # number_have: Optional[int] = Field(0)
    is_accompany: Optional[bool] = True
    times: Optional[bool] = True
    status: Optional[bool] = True
    need_parking: Optional[bool] = True
    show_add: Optional[int] = Field(0)
    parking_price: Optional[int] = Field(0)

class AppointmentSalonCreate(BaseAppointmentSalon):
    role_id: Optional[list] = None
    content_pic: Optional[list] = None

class AppointmentSalonUpdate(BaseAppointmentSalon):
    id: int
    role_id: Optional[list] = None
    content_pic: Optional[list] = None
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})

class BaseAppointmentList(BaseModel):
    type: Optional[int] = Field(1)
    d_type: Optional[int] = Field(1)
    time: Optional[datetime]
    city_id: Optional[int] = Field(1)
    space_id: Optional[int] = Field(1)
    designer_ids: Optional[list] = Field(None)
    designer_names: Optional[list] = Field(None)
    project_id: Optional[int] = Field(0)
    project_name: Optional[str] = Field(None)
    ex_project_ids: Optional[list] = Field(None)
    ex_project_names: Optional[list] = Field(None)
    user_id: Optional[int] = Field(0)
    user_name: Optional[str] = Field(None)
    user_card_no: Optional[int] = Field(0)
    user_type: Optional[int] = Field(1)
    user_phone: Optional[str] = Field(None)
    cancel_time:Optional[datetime]
    extend: Optional[str] = Field(None)
    status: Optional[int] = Field(0)
    come_nums: Optional[int] = Field(1)
    order_id: Optional[int] = Field(0)
    longs: Optional[int] = Field(0)

class AppointmentListCreate(BaseAppointmentList):
    cancel_time: Optional[str] = Field(None)
    extend: Optional[list] = None

class AppointmentListUpdate(BaseAppointmentList):
    id: int
    cancel_time: Optional[str] = Field(None)
    extend: Optional[list] = None

    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})


class BaseAppointmentLock(BaseModel):
    user_id : Optional[int] = Field(0)
    designer_ids: Optional[list] = Field(None)
    longs: Optional[int] = Field(0)
    time : Optional[datetime]

class AppointmentLockCreate(BaseAppointmentLock):
    ...

class AppointmentLockUpdate(BaseAppointmentLock):
    id: int

    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})


class AppointmentCategory(BaseModel):
    name: str = Field(..., description="分类名称", example="类目名称1")
    desc: Optional[str] = Field("", description="备注", example="备注1")
    order: int = Field(0, description="排序")
    parent_id: int = Field(0, description="父分类ID")
    cover: Optional[str] = Field("", description="封面")
    goods_id: Optional[int]  = Field(0, description="关联商品ID")
    sku_id: Optional[int] = Field(0, description="关联规格ID")


class AppointmentCategoryCreate(AppointmentCategory):
    ...


class AppointmentCategoryUpdate(AppointmentCategory):
    id: int
    def update_dict(self):
        return self.model_dump(exclude_unset=True, exclude={"id"})


class AppointmentGetPrice(BaseModel):
    ex_project_ids: Optional[list] = Field(None)
    project_id: Optional[int] = Field(0)
    come_nums: Optional[int] = Field(1)

